package com.zhigh.test.testuinit.sty.pojo;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.*;

import java.util.ArrayList;
import java.util.List;

@Setter
@Getter
@ToString
public class ESBArrayData<T extends ESBData> extends ESBData{

    @JacksonXmlElementWrapper(localName = "array")
    @JacksonXmlProperty(localName = "data")
    private List<T> fields;

    public ESBArrayData(String name, List<T> fields) {
        super(name);
        this.fields = fields;
    }

    @Override
    public ESBData addObject(ESBObjectData objectData) {
        if (fields == null) {
            fields = new ArrayList<>();
        }

        fields.add((T)objectData);
        return this;
    }
}
